<?php

/**
 * Description of ApiService
 *
 * @author gun
 */

class Web_Model_ResourceService extends Web_Model_BaseService {
    protected $daoClass = 'Web_Model_DbTable_Resource';
    
    public function getAll($where = array()) {
        $data = $this->getDao()->getAll($where);
        $category = $this->getCategory();
        
        foreach ($data as $key => $value) {
            foreach ($category as $k => $v) {
                if ($v['catID'] === $value['category'])
                    $data[ $key ]['category'] =  $v['name'];
            }
        }
        
        return $data;
    }
    
    public function getResourceInformation($resID = NULL) {
        $data = $this->getDao()->getResourceInformation($resID);        
        $category = $this->getCategory();                
        

        foreach ($category as $k => $v) {
            if ($v['catID'] === $data['family'])
                $data['family'] =  $v['name'];
        }
        
        return $data;
    }
    
    public function getCategory() {
        return $this->getDao()->getCategory();
    }
    
    public function getResAndCategory() {
        return $this->getDao()->getResAndCategory();
    }
}
